﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BDS3M.Controls
{
    public partial class ContentTop : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {

                    DataTable dt = DAL.DCollector.DBCollector.Instance.StoredSelectAllTable("tbl_LienKetWeb");
                    ListItem lt = new ListItem("Chọn liên kết", "1");
                    ddl_lienketweb.Items.Add(lt);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        lt = new ListItem(dt.Rows[i]["LienKetWeb_TieuDe"].ToString(), dt.Rows[i]["LienKetWeb_Link"].ToString());
                        ddl_lienketweb.Items.Add(lt);
                    }
                    ddl_lienketweb.SelectedIndex = 0;
                }
                catch (Exception)
                {
                    Response.Redirect("/error");
                }

                if (Session["Username"] != null)
                {
                    string user = Session["Employee_FullName"].ToString();
                    lblLoginUser.Text = user.ToUpper();
                }


            }
        }

        protected void lbtThoat_Click(object sender, EventArgs e)
        {
            if (Request.Cookies["CookieUser"] != null)
            {
                HttpCookie cki = new HttpCookie("CookieUser");
                cki.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(cki);
            }
            HttpContext.Current.Session["SHOPPING"] = null;
            BOL.Shopping.ShoppingCart.Instance.dataItems = null;
            Session["Username"] = null;
            Session.RemoveAll();
            Response.Redirect("~/home");
        }

        protected void ddl_lienketweb_SelectedIndexChanged(object sender, EventArgs e)
        {
            Response.Redirect(ddl_lienketweb.SelectedValue);
        }

    }
}